import 'package:flutter/material.dart';
import 'package:sample2/model/chat/chat_group.dart';
import 'package:sample2/pages/chat/chat_conversation.dart';

class ChatGroupItem extends StatefulWidget {
  final ChatGroup chatGroup;
  const ChatGroupItem({required this.chatGroup, super.key});

  @override
  State<StatefulWidget> createState() {
    return ChatGroupItemState();
  }
}

class ChatGroupItemState extends State<ChatGroupItem> {
  @override
  Widget build(BuildContext context) {
    return InkWell(
        onTap: () {
          // AlertHelper.showAlert(context: context, message: "test");
          Navigator.of(context).pushNamed("/chatMessage", arguments: {
            "group": widget.chatGroup,
            "kind": ChatConversationKind.peer2group
          });
        },
        child: Container(
          padding: const EdgeInsets.all(13),
          width: MediaQuery.of(context).size.width,
          constraints: const BoxConstraints(minHeight: 50, maxHeight: 80),
          child: Row(
            children: [
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    widget.chatGroup.groupName!,
                  ),
                  const Spacer(),
                  Text(widget.chatGroup.groupDesc!)
                ],
              ),
              const Spacer(),
              Column(
                children: [
                  Text("200"), //TODO:add the member count
                  const Spacer(),
                ],
              )
            ],
          ),
        ));
  }
}
